home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3530 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: casbah.acns.nwu.edu!muzaffar
  2. From: muzaffar@casbah.acns.nwu.edu (Usman Muzaffar)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: A question about STRING.
  5. Date: 29 Jan 1996 19:24:28 GMT
  6. Organization: Northwestern University, Evanston IL
  7. Message-ID: <4ej6tc$svf@news.acns.nwu.edu>
  8. References: <4e0akh$853@erinews.ericsson.se>
  9. NNTP-Posting-Host: casbah.acns.nwu.edu
  10.  
  11. In article <4e0akh$853@erinews.ericsson.se>,
  12. wei he (martletts)  <etlwihe@etlxdmx.ericsson.se> wrote:
  13. >Hi there,
  14. >
  15. >I have a problem with 'C' and need your help.
  16. >
  17. >In my program, there is a variable MUTLI_RECORDS defined as char, which has a
  18. >typical string as following:
  19. >
  20. >1,0,a,map010017000802532236,1,pp,0.2,1,0,map010017000802532236,acc,1,0. ...
  21. >
  22. >In fact, this string contains many records. Each record contains seven columns.
  23. >The columns in each record are seperated by the comma ','. Each record is 
  24. >terminated by a full stop '.'.
  25. >
  26. >What I want to do is to have a loop. In each loop, one record is extracted 
  27. >from the MULTI_RECORDS and the different columns in this record are assigned to
  28. >different variables. 
  29. >
  30. >As the program is to run on a real time system, I have to keep the loops equal
  31. >to the number of records hold in the MULTI_RECORDS, no inner loop is allowed.
  32.  
  33. Doesn't the strtok function in the standard library do just this for you?
  34. Split up an incoming string into tokens, and assign one to each. 
  35. Although, a simple while loop could do the trick, too.
  36.  
  37.  
  38.